package com.gzu.ltms.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 订单主表 表定义层。
 *
 * @author mm
 * @since 2025-05-06
 */
public class OrderDetailTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 订单主表
     */
    public static final OrderDetailTableDef ORDER_DETAIL = new OrderDetailTableDef();

    /**
     * 运费
     */
    public final QueryColumn FEE = new QueryColumn(this, "fee");

    /**
     * 包裹状态
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * 用户ID
     */
    public final QueryColumn USER_ID = new QueryColumn(this, "user_id");

    /**
     * 重量（kg）
     */
    public final QueryColumn WEIGHT = new QueryColumn(this, "weight");

    /**
     * 订单号（业务生成）
     */
    public final QueryColumn ORDER_ID = new QueryColumn(this, "order_id");

    /**
     * 配送距离（米）
     */
    public final QueryColumn DISTANCE = new QueryColumn(this, "distance");

    /**
     * 配送员ID
     */
    public final QueryColumn COURIER_ID = new QueryColumn(this, "courier_id");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 寄件人姓名
     */
    public final QueryColumn SENDER_NAME = new QueryColumn(this, "sender_name");

    /**
     * 寄件人电话
     */
    public final QueryColumn SENDER_PHONE = new QueryColumn(this, "sender_phone");

    /**
     * 收件人姓名
     */
    public final QueryColumn RECEIVER_NAME = new QueryColumn(this, "receiver_name");

    /**
     * 收件人电话
     */
    public final QueryColumn RECEIVER_PHONE = new QueryColumn(this, "receiver_phone");

    /**
     * 寄件地址
     */
    public final QueryColumn SENDER_ADDRESS = new QueryColumn(this, "sender_address");

    /**
     * 收货人地址
     */
    public final QueryColumn RECEIVER_ADDRESS = new QueryColumn(this, "receiver_address");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ORDER_ID, USER_ID, SENDER_NAME, SENDER_PHONE, SENDER_ADDRESS, RECEIVER_NAME, RECEIVER_PHONE, RECEIVER_ADDRESS, WEIGHT, DISTANCE, FEE, STATUS, COURIER_ID, CREATE_TIME};

    public OrderDetailTableDef() {
        super("", "order_detail");
    }

    private OrderDetailTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public OrderDetailTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new OrderDetailTableDef("", "order_detail", alias));
    }

}
